<?php defined('IN_ADMIN') or exit('Access Denied!'); ?>

<style>span.tel{height:36px;width:120px;display:block;overflow-y:scroll;border:1px #ccc dotted;}</style>
<div class="subnav">
  <div class="content-menu ib-a blue line-x"> <a href='javascript:;' class="on"><em>商户管理</em></a> <span>|</span>
    <?php if($isadmin){ ?>
    <a href="/admin/shop/create?shop_type=<?=array_get_int($_GET, 'shop_type');?>"><em>添加新商户</em></a> <span>|</span>
    <a href="#" onclick="$('#search').toggle()"><em>搜索</em></a>
    <?php } ?>
  </div>
</div>
<form method="get" action="/admin/shop/list" name="searchform">
  <div class="pad_10" style="<?php if(!(isset($search['zone_id']) || isset($search['subzone_id']) || isset($search['q']))){?>display:none<?php } ?>" id="search">
    <table width="100%" cellspacing="0" class="search-form">
      <tbody>
        <tr>
          <td><div class="explain-col">
              区域：
              <select name="zone_id" id="zone_id" rel="<?=i($search['zone_id']);?>">
                <option value="0" selected>请选择...</option>
              </select>
              /
              <select name="subzone_id" id="subzone_id" rel="<?=i($search['subzone_id']);?>">
                <option value="0" selected>请选择...</option>
              </select>
              <input type="text" class="input-text" value="<?=urldecode(h($search['q']));?>" name="q">
              <input type="hidden" value="<?=i($search['shop_type']);?>" name="shop_type">
              <input type="submit" value="搜索" class="button" />
            </div></td>
        </tr>
      </tbody>
    </table>
  </div>
</form>
<form name="myform" action="/admin/shop/sortlist" method="post">
  <div class="pad_10">
    <div class="table-list">
      <table width="100%" cellspacing="0" >
        <thead>
          <tr>
            <th width="38">排序</th>
            <th width="30">Id</th>
            <th>商户名称</th>
            <th width="30">类型</th>
            <th align="left" width="120">电话</th>
            <th align="center" width="40">访问量</th>
            <th align="center" width="80">管理员ID</th>
            <th align="center" width="120">最后更新</th>
            <th align="center">管理操作</th>
          </tr>
        </thead>
        <tbody>
        <?php
        if(is_array($list) && count($list)){
          foreach($list as $item){
        ?>
          <tr>
            <td align="center" height="42"><input name="sorts[<?=$item['shop_id'];?>]" type="text" size="3" value="<?=$item['ordnum'];?>" class="input-text-c"></td>
            <td align="center"><?=$item['shop_id'];?></td>
            <td><a target="_blank" href="<?php if($item['shop_type']==2) { echo '/hotel'; } else { echo '/shop'; } ?>/<?=$item['shop_id'];?>?force=1">
                    <span style="font-size:14px;font-weight:bold;"><?=h($item['name']);?></span></a>
                <?php if($item['alias_name']){ ?><br /><font color="grey"><?=h($item['alias_name']);?></font><? } ?>
            </td>
            <td align="center">
            <?php
                if($item['shop_type']==1){
                    echo '<font color="red">外</font>';
                }else if($item['shop_type']==2){
                    echo '<font color="green">酒</font>';
                }
            ?>
            <td><span class="tel" title="<?=str_replace('/', "\n", '预约电话：/'.$item['telphone']);?>"><?=str_replace('/', "<br />", $item['telphone']);?></span></td>
            <td align="center"><?=intval($item['views']);?></td>
            <td align="center"><?php if(intval($item['admin_uid'])){ ?>
              <a href="/admin/hotel/list?admin_uid=<?=intval($item['admin_uid']);?>">
              <?=intval($item['admin_uid']);?>
              </a>
              <?php } ?></td>
            <td align="center"><?=h($item['update_dt']);?></td>
            <td align="center">
                <a href="javascript:window.top._M(<?=i($item['shop_type']);?>, <?=i($item['shop_id']);?>, '<?=h($item['name']);?>');">店铺管理</a>
            <?php if($isadmin){ ?>
                <span>|</span><a href="#" onclick="alert('该功能暂时无效')">删除</a>
            <?php } ?>
            </td>
          </tr>
        <?php
            }
          }else{
        ?>
            <tr><td colspan="9" height="50" align="center">暂无数据</td></tr>
        <?php } ?>
        </tbody>
      </table>
      <div class="btn">
        <input type="submit" class="button" name="dosubmit" value="排序" />
            &nbsp; <span>|</span> <a href="/admin/shop/cache?shop_type=<?=array_get_int($_GET, 'shop_type');?>" onClick="return confirm('单击确定开始批量更新缓存')">批量更新缓存</a>
      </div>
      <?php if($pages){ ?>
      <div id="pages">
        <?=$pages;?>
      </div>
      <?php };?>
    </div>
  </div>
</form>
